﻿/*
 * Dialog
 * 
 */
function ConfirmDialog(content, callBack) {
    var d = dialog({
        title: '提示',
        width: '300px',
        content: content,
        okValue: '确定',
        ok: callBack,
        cancelValue: '取消',
        cancel: function () { }
    });
    d.showModal();
}
function AlertDialog(content, callBack) {
    if (callBack == undefined) {
        callBack = function () { }
    }
    var d = dialog({
        width:'300px',
        title: '提示',
        content: content,
        okValue: '确定',
        ok: callBack
    });
    d.showModal();
}
/*
 * Load
 */
function Loading()
{
    dialog({
        id: 'dialog-Loading'
    }).showModal();
}
function Loadend() {
    dialog.get('dialog-Loading').close().remove();
}

/*
 * ajax
 */
function AjaxPost(url, Data, callBack) {
    $.ajax({
        url:url,
        type: "post",
        data: Data,
        dataType: "json",
        beforeSend: function () {
            Loading();
        },
        success: callBack,
        error: function (data) {
            AlertDialog("AjaxJson：数据加载出错！");
        },
        complete: function () {
            Loadend();
        }
    });
}
function AjaxGet(url, Data, callBack) {
    $.ajax({
        url:url,
        type: "get",
        data: Data,
        dataType: "json",
        beforeSend: function () {
            Loading();
        },
        success: callBack,
        error: function (data) {
            AlertDialog("AjaxJson：数据加载出错！");
        },
        complete: function () {
            Loadend();
        }
    });
}

//js获取网站根路径(站点及虚拟目录)
function RootPath() {
    var strFullPath = window.document.location.href;
    var strPath = window.document.location.pathname;
    var pos = strFullPath.indexOf(strPath);
    var prePath = strFullPath.substring(0, pos);
    var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
    //return (prePath + postPath);//有虚假目录用这句
    return (prePath);
   
}